//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.zqathserver.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping({"/"})
@ResponseBody
public class ZQController {
    private static final String APP_ID = "appId111";
    private static final String VALID_ACCESS_TOKEN = "accessToken111";
    private static final String APP_SECRET = "appSecret111";

    public ZQController() {
    }

    @PostMapping({"/getAccessToken"})
    public ResponseEntity<Map<String, Object>> getAccessToken(@RequestBody Map<String, Object> map) {
        System.out.println("getAccessTokengetAccessToken");
        String appId = map.get("appId").toString();
        String appSecret = map.get("appSecret").toString();
        Map<String, Object> response = new HashMap();
        if ("appId111".equals(appId) && "appSecret111".equals(appSecret)) {
            response.put("code", "200");
            response.put("message", "调用成功");
            response.put("accessToken", "accessToken111");
        } else {
            response.put("code", "401");
            response.put("message", "认证失败");
        }

        return ResponseEntity.ok(response);
    }

    @PostMapping({"/getTicketInfo"})
    public ResponseEntity<Map<String, Object>> getTicketInfo(@RequestBody Map<String, Object> map) {
        System.out.println("getTicketInfo");
        String accessToken = map.get("accessToken").toString();
        String ticket = map.get("ticket").toString();
        Map<String, Object> response = new HashMap();
        if ("accessToken111".equals(accessToken)) {
            if ("ticket".equals(ticket)) {
                response.put("code", "200");
                response.put("message", "调用成功");
                response.put("userName", "姚佳鑫");
                response.put("realName", "姚佳鑫");
                response.put("workNo", "1981");
                response.put("avatar", "");
            } else {
                response.put("code", "404");
                response.put("message", "票据无效");
            }
        } else {
            response.put("code", "401");
            response.put("message", "AccessToken 无效");
        }

        return ResponseEntity.ok(response);
    }
}

